package net.zdreamer.geracomium.ui.more;

import net.zdreamer.geracomium.ui.BaseActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;

import com.example.geracomium.R;

public class EditAdressActivity extends BaseActivity implements OnClickListener {
	private TextView tv_address;
	private EditText edit_address;
	private String  source;
	public static String back_address,edit_index;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	}

	@Override
	protected int getContentView() {
		// TODO Auto-generated method stub
		return R.layout.activity_editadress;
	}

	@Override
	protected void init() {

		tv_address = (TextView) findViewById(R.id.choose_adress);
		edit_address = (EditText) findViewById(R.id.edit_adress);
	}

	@Override
	protected void initViews() {
		initTitle("编辑地址", R.drawable.selector_title_back,
				R.drawable.seletor_save, true, true);
		Intent intent = getIntent();
		tv_address.setText(intent.getStringExtra("address"));
		edit_index = intent.getStringExtra("index");
		//System.out.println(edit_index);
		source = intent.getStringExtra("source");
	}

	@Override
	protected void initListener() {
		// TODO Auto-generated method stub
		findViewById(R.id.back).setOnClickListener(this);
		findViewById(R.id.share).setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.back:
			EditAdressActivity.this.finish();
			break;
		case R.id.share:
			back_address = tv_address.getText().toString()
					+ edit_address.getText().toString();
			EditAdressActivity.this.finish();
			break;
		default:
			break;
		}
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == event.KEYCODE_BACK) {
			Intent intent = new Intent(EditAdressActivity.this,
					ChooseAdressActivity.class);
			startActivity(intent);
			
			EditAdressActivity.this.finish();
		}
		return super.onKeyDown(keyCode, event);
	}

}
